package com.thinkin.services.util;

public class InitSQL {

	public static String str_sql = String
			.format("select ' ' as value,' ' as label from dual union all ");

	/**
	 * 获取客户状态sql
	 * 
	 * @return 放回sql
	 */
	public static String InitcusstateSQL() {
		StringBuffer str_SQL = new StringBuffer();
		str_SQL.append(str_sql);
		str_SQL.append("select codename as value,codename as label from e_cusstate where 1=1");
		str_SQL.append(" and nvl(stateid,'F')='F'");
		return str_SQL.toString();
	}

	/**
	 * 获取客户等级sql
	 * 
	 * @return
	 */
	public static String InitcuslevelSQL() {
		StringBuffer str_SQL = new StringBuffer();
		str_SQL.append(str_sql);
		str_SQL.append("select codename as value,codename as label from e_cuslevel where 1=1");
		str_SQL.append(" and nvl(stateid,'F')='F'");
		return str_SQL.toString();
	}

	/**
	 * 获取结算方式sql
	 * 
	 * @return
	 */
	public static String InitsettlementSQL() {
		StringBuffer str_SQL = new StringBuffer();
		str_SQL.append(str_sql);
		str_SQL.append("select codecd as value,codename as label from e_settlement where 1=1");
		str_SQL.append(" and nvl(stateid,'F')='F'");
		return str_SQL.toString();
	}

	/**
	 * 获取客户属性sql
	 * 
	 * @return
	 */
	public static String InitcusattributeSQL() {
		StringBuffer str_SQL = new StringBuffer();
		str_SQL.append(str_sql);
		str_SQL.append("select codecd as value,codename as label from e_cusattribute where 1=1");
		str_SQL.append(" and nvl(stateid,'F')='F'");
		return str_SQL.toString();
	}

	/**
	 * 获取行业分类sql
	 * 
	 * @return
	 */
	public static String InitidtclassSQL() {
		StringBuffer str_SQL = new StringBuffer();
		str_SQL.append(str_sql);
		str_SQL.append("select codename as value,codename as label from e_idtclass where 1=1");
		str_SQL.append(" and nvl(stateid,'F')='F'");
		return str_SQL.toString();
	}

	/**
	 * 获取企业类型sql
	 * 
	 * @return
	 */
	public static String InittypeofetpSQL() {
		StringBuffer str_SQL = new StringBuffer();
		str_SQL.append(str_sql);
		str_SQL.append("select codename as value,codename as label from e_typeofetp where 1=1");
		str_SQL.append(" and nvl(stateid,'F')='F'");
		return str_SQL.toString();
	}

	/**
	 * 获取企业性质sql
	 * 
	 * @return
	 */
	public static String InitntofetpSQL() {
		StringBuffer str_SQL = new StringBuffer();
		str_SQL.append(str_sql);
		str_SQL.append("select codename as value,codename as label from e_ntofetp where 1=1");
		str_SQL.append(" and nvl(stateid,'F')='F'");
		return str_SQL.toString();
	}

	/**
	 * 获取所有组织sql
	 * 
	 * @return
	 */
	public static String InitAllOrgSQL() {
		StringBuffer str_SQL = new StringBuffer();
		str_SQL.append(str_sql);
		str_SQL.append("select orgcd as value,orgname as label from s_organization where 1=1");
		str_SQL.append(" order by value");
		return str_SQL.toString();
	}

	/**
	 * 获取组织sql,本身组织以及下级组织
	 * 
	 * @return
	 */
	public static String InitOrganizationSQL(String Orgcd) {
		StringBuffer str_SQL = new StringBuffer();
		str_SQL.append(str_sql);
		str_SQL.append("select orgcd as value,orgname as label from s_organization where 1=1");
		if (Orgcd.length() > 0) {
			str_SQL.append(String.format(" and orgcd like '%1$s%%'", Orgcd));
		}
		str_SQL.append(" order by value");
		return str_SQL.toString();
	}

	/**
	 * 获取省份数据SQL
	 * 
	 * @return
	 */
	public static String InitProSQL() {
		StringBuffer str_SQL = new StringBuffer();
		str_SQL.append(str_sql);
		str_SQL.append("select areaid as value,areaname as label from e_area where 1=1 and parentid='86'");
		return str_SQL.toString();
	}

	/**
	 * 获取市区
	 * 
	 * @return
	 */
	public static String InitActOrSubSQL(String Parentcd) {
		StringBuffer str_SQL = new StringBuffer();
		str_SQL.append(str_sql);
		str_SQL.append("select areaid as value,areaname as label from e_area where 1=1");
		str_SQL.append(String.format(" and parentid='%1$s'", Parentcd));
		return str_SQL.toString();
	}

	/**
	 * 获取币别
	 * 
	 * @return
	 */
	public static String InitCurrSQL() {
		StringBuffer str_SQL = new StringBuffer();
		str_SQL.append(str_sql);
		str_SQL.append("select currcd as value,currcd as label from e_currency where 1=1");
		return str_SQL.toString();
	}

	public static String InitQuantityunit() {
		StringBuffer str_SQL = new StringBuffer();
		str_SQL.append(str_sql);
		str_SQL.append("select unitcd as value,unitname as label from E_UNIT where 1=1");
		str_SQL.append(" AND typelist like '%Q%' ");
		str_SQL.append(" AND stateid like 'T' ");
		return str_SQL.toString();
	}

	public static String InitPieceunit() {
		StringBuffer str_SQL = new StringBuffer();
		str_SQL.append(str_sql);
		str_SQL.append("select unitcd as value,unitname as label from E_UNIT where 1=1");
		str_SQL.append(" AND typelist like '%P%' ");
		str_SQL.append(" AND stateid like 'T' ");
		return str_SQL.toString();
	}

	public static String InitWeightunitt() {
		StringBuffer str_SQL = new StringBuffer();
		str_SQL.append(str_sql);
		str_SQL.append("select unitcd as value,unitname as label from E_UNIT where 1=1");
		str_SQL.append(" AND typelist like '%W%' ");
		str_SQL.append(" AND stateid like 'T' ");
		return str_SQL.toString();
	}

	public static String InitVolumeunit() {
		StringBuffer str_SQL = new StringBuffer();
		str_SQL.append(str_sql);
		str_SQL.append("select unitcd as value,unitname as label from E_UNIT where 1=1");
		str_SQL.append(" AND typelist like '%V%' ");
		str_SQL.append(" AND stateid like 'T' ");
		return str_SQL.toString();
	}

	public static String InitSizeunit() {
		StringBuffer str_SQL = new StringBuffer();
		str_SQL.append(str_sql);
		str_SQL.append("select unitcd as value,unitname as label from E_UNIT where 1=1");
		str_SQL.append(" AND typelist like '%S%' ");
		str_SQL.append(" AND stateid like 'T' ");
		return str_SQL.toString();
	}

	public static String InitQuanlity() {
		StringBuffer str_SQL = new StringBuffer();
		str_SQL.append(str_sql);
		str_SQL.append("select quanlityname as value,quanlityname as label from e_quanlity where 1=1");
		return str_SQL.toString();
	}

	public static String initEcondition() {
		StringBuffer str_SQL = new StringBuffer();
		str_SQL.append(str_sql);
		str_SQL.append("select conditioncd as value,conditionname as label from e_condition where 1=1");
		return str_SQL.toString();

	}

	public static String InitBizoptype() {
		StringBuffer str_SQL = new StringBuffer();
		str_SQL.append(str_sql);
		str_SQL.append("select operatename as value,operatename as label from e_bizoptype where 1=1");
		return str_SQL.toString();
	}

	public static String InitOrgnization() {
		StringBuffer str_SQL = new StringBuffer();
		str_SQL.append(str_sql);
		str_SQL.append("select * from e_orgnization where 1=1");
		return str_SQL.toString();
	}

	public static String InitCustomer() {
		StringBuffer str_SQL = new StringBuffer();
		str_SQL.append(str_sql);
		str_SQL.append("SELECT keyid as value, cusnamecn as label FROM  e_customer where 1=1");
		return str_SQL.toString();
	}

	/**
	 * 系统代码sql
	 * 
	 * @return
	 */
	public static String InitCodeLibSQL(String CodeClass) {
		StringBuffer str_SQL = new StringBuffer();
		str_SQL.append(str_sql);
		str_SQL.append("select codecd as value,codename as label from e_codelib ");
		str_SQL.append(String.format(
				"where  codeclass = '%1$s' order by value", CodeClass));
		return str_SQL.toString();
	}
}
